home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 32
/
Mac Magazin and MacEasy Magazine CD - Issue 32.iso
/
Online
/
map2html ƒ
/
map2html.pl
< prev
next >
Wrap
Perl Script
|
1997-02-26
|
1KB
|
58 lines
#!/usr/bin/perl
#
# map2HTML 0.1b2 -- Parses an NCSA imagemap as created by webmap, and munges
# it into something suitable for cut-and-paste into an
# HTML document.
#
# (c) Wink, wink@nicom.com 2/26/97
#
while (@ARGV) {
$input = shift;
if ($input =~ /STDIN/) { # We're using Alpha
$mapname = "•.map";
$imagename = "•";
$handle = "STDOUT";
} else { # Dropped files
$mapname = $input;
$mapname =~ s/.*://;
$imagename = "$mapname";
$imagename =~ s/.map$//;
$handle = "FILE";
$file = $input . ".out";
open($handle, ">$file") or die "Can't create $file: $!\n";
}
$in = "IN";
open(IN,"$input") or die "Can't open $input: $!\n";
print $handle "<MAP NAME=\"$mapname\">\n";
while (<$in>) {
if (/^\w/) {
if (/^default/) {
($keyword, $default_url) = split;
print $handle "<AREA SHAPE=\"default\" HREF=\"$default_url\">\n";
} else {
s/(\d)\s(\d)/$1,$2/g;
($shape, $url, $coords) = split;
print $ handle "<AREA SHAPE=\"$shape\" COORDS=\"$coords\" HREF=\"$url\">\n";
}
}
}
print $handle "</MAP>\n";
print $handle "<IMG USEMAP=\"\#$mapname\" SRC=\"$imagename\" BORDER=0>\n";
close($handle);
close($in);
}